﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WordPressSharp;

namespace MoetutuServer.PostHelper
{
    class UserInfoHelper
    {    /// <summary>
         /// 初始化并且返回用户信息
         /// </summary>
         /// <param name="UserInfoPath"></param>
         /// <returns></returns>
        public static WordPressSiteConfig ReadUserInfo(String UserInfoPath)
        {
            LoadUserInfo.UserData UserInfo = LoadUserInfo.GetUserData(UserInfoPath);

            return InitWpConfig(UserInfo);
        }


        /// <summary>
        /// 处理UserData类型的数据并且返回结果
        /// </summary>
        /// <param name="userData"></param>
        /// <returns></returns>
        public static WordPressSiteConfig InitWpConfig(LoadUserInfo.UserData userData)
        {
            return new WordPressSiteConfig
            {
                BaseUrl = userData.WebHost,
                Username = userData.UserName1,
                Password = userData.UserPass1,
                BlogId = 1
            };
        }
    }
}
